import axios from 'axios'; // 引入axios
import {Message} from "element-ui"
const service = axios.create({
    baseURL: '', // url = base api url + request url
    withCredentials: true, // send cookies when cross-domain requests
    timeout: 1000*12 // 请求超时
  })
  // 设置post请求头
service.defaults.headers.post['Content-Type'] = 'application/json; charset=utf-8';
// 请求拦截器
service.defaults.headers.post['XX-Device-Type'] ='pc'
service.interceptors.request.use(
  config => {
    return config
  },
  error => {
    // do something with request error
   
    return Promise.reject(error)
  }
)
// 响应拦截器
service.interceptors.response.use(
    response => {   
      console.log(response);
      
        return Promise.resolve(response);    
    },    

    error => {  
        console.log(error);          
  
});
//最后导出实例
export default service;